import requests from "./request";

// 登录请求
export const reqLogin = (data) => requests({ url: '/users/login', method: 'post', data })

//检验用户名是否重名
export const reqCheckName = (nickname) => requests({ url: `/users/checkNickname/${nickname}`, method: 'get' })

//发送邮箱验证码
export const reqMailCode = (mail) => requests({ url: `/checkCode/mailCode/${mail}`, method: 'get' })

//注册
export const reqRegister = (emailCode, data) => requests({ url: `/users/registered/${emailCode}`, method: 'post', data })

// // 获取登录用户信息
// export const reqGetUserInfo = () => requests({ url: '/users/username', method: 'get' })

//退出登录
export const reqLoginOut = () => requests({ url: '/users/quit', method: 'get' })

//自动登录
export const reqAutoLogin = () => requests({ url: '/users/autoLogin', method: 'get' })

//搜索帖子
export const reqSearch = (uid = 1, page, size, param, read) => {
    if (param) {
        // return requests({ url: `/messages/search?words=${keyword}`, method: 'get' })
        return requests({ url: `/messages/searchMessages?page=${page}&size=${size}&param=${param}&uid=${uid}`, method: 'post', data: read })
    } else {
        return requests({ url: `/messages/listSomeMessages?uid=${uid}`, method: 'post', data: read })
        // return requests({ url: `/messages/search?page=${page}&size=${size}&param=${param}`, method: 'get' })
    }
}

//得到消息数量
export const reqGetMessage = () => requests({ url: '/comments/getAlertNum', method: 'get' })

//得到未读消息数量
export const reqGetUnReadMsg = () => requests({ url: '/messages/getMyUnCheckedSubsNum', method: 'get' })

//查看关注人动态
// export const reqGetSub=()=>requests({url:})

//更新头像
export const reqUpAvatar = () => requests({ url: '/images/updateAvatar', method: 'get' })

// 帖子图像
export const reqImageUpload = () => requests({ url: '/images/upload', method: 'get' })

//点赞
export const reqKudos = (mid) => requests({ url: `/messages/addLikes/${mid}`, method: 'get' })

//取消赞
export const reqCancelKudos = (mid) => requests({ url: `/messages/cancelLikes/${mid}`, method: 'get' })

// 发帖
export const reqEditMsg = (data) => requests({ url: '/messages/saveOneMessage', method: 'post', data })

//查看帖子（分页）
// export const reqGetMessageByPage = (page, size, param) => requests({ url: `/messages/search?page=${page}&size=${size}&param=${param}`, method: 'get' })

//获取关注列表
export const reqGetConcernList = (uid, otherId) => requests({ url: `/users/listSubscribes/${uid}/${otherId}`, method: 'get' })

//查看一条帖子
export const reqGetMessageDetail = (mid) => requests({ url: `/messages/getOneMessage/${mid}`, method: 'get' })

//得到所以评论
export const reqGetAllComments = (mid, uid) => requests({ url: `/comments/listCommentByMid/${mid}/${uid}`, method: 'get' })

//查看别人信息
export const reqGetOtherPeopleInfo = (uid) => requests({ url: `/users/getDetail/${uid}`, method: 'get' })

//是否关注某人
export const reqIsConcern = (uid) => requests({ url: `/users/hasSubscribed/${uid}`, method: 'get' })

//关注某人
export const reqConcernPeople = (uid) => requests({ url: `/users/subscribe/${uid}`, method: 'put' })

//取关某人
export const reqCancelConcern = (uid) => requests({ url: `/users/cancelSubscribe/${uid}`, method: 'put' })

//给评论点赞
export const reqKudosComment = (id) => requests({ url: `/comments/addLikes/${id}`, method: 'get' })

//取消评论赞
export const reqCancelKudosComment = (id) => requests({ url: `/comments/cancelLikes/${id}`, method: 'get' })

// // 发评论(父级)
// export const reqSendFComment = (data) => requests({ url: '/comments/addAFatherComment', method: 'post', data })

// // 发评论(子级)
// export const reqSendSComment = (data) => requests({ url: '/comments/addASonComment/', method: 'post', data })

//发送评论
export const reqSendComment = (data) => requests({ url: `/comments/addAComment`, method: 'post', data })


//删帖
export const reqDeleteMessage = (mid) => requests({ url: `/messages/changeOneMessageStatus/${mid}/-1`, method: 'put' })

// //删父评
// export const reqDeleteFatherComment = (id) => requests({ url: `/comments/changeOneFatherCommentStatus/${id}/-1`, method: 'put' })

// //删子评
// export const reqDeleteSonComment = (id) => requests({ url: `/comments/changeOneSonCommentStatus/${id}/-1`, method: 'put' })

//删评论
export const reqDeleteComment = (id) => requests({ url: `/comments/changeStatus/${id}/-1`, method: 'put' })


//查看用户所有帖子
export const reqGetUserAllMessages = (uid, otherId) => requests({ url: `/messages/listWhoseMessages/${uid}/${otherId}`, method: 'get' })

//查询用户点赞过的帖子
export const reqUserLikesMsg = (uid, otherId) => requests({ url: `/messages/listWhoseLike/${uid}/${otherId}`, method: 'get' })

//查看粉丝
export const reqUserFans = (uid, otherId) => requests({ url: `/users/listFans/${uid}/${otherId}`, method: 'get' })

//浏览量加1
export const reqAddViews = (mid) => requests({ url: `/messages/addViews/${mid}`, method: 'get' })

//得到点赞人
export const reqKudosPeople = (mid, num) => requests({ url: `/messages/getWhoLikesMessages/${mid}/${num}` })

//按昵称查找某人
export const reqSearchUser = (page, size, nickname, uid) => requests({ url: `/users/searchUser?page=${page}&size=${size}&nickname=${nickname}&uid=${uid}`, method: 'get' })

//修改个人信息
export const reqUpdateUserInfo = (data) => requests({ url: `/users/update`, method: 'post', data })

//查看某父评论的所有子评论
export const reqGetAllSonComments = (parentId, uid) => requests({ url: `/comments/getSonComments/${parentId}/${uid}`, method: 'get' })